package com.hu.zhcc.shiro.service;


import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hu.zhcc.shiro.dao.TJ_TMemberMapper;
import com.hu.zhcc.shiro.dao.Tj_VipsettingMapper;
import com.hu.zhcc.shiro.entity.tj.TMember;
import com.hu.zhcc.shiro.entity.tj.TMemberExamination;
import com.hu.zhcc.shiro.entity.tj.VipdaTj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 会员表 服务实现类
 * </p>
 *
 * @author tj
 * @since 2021-06-11
 */
@Service
public class TJ_TMemberServiceImpl extends ServiceImpl<TJ_TMemberMapper, TMember> implements TJ_TMemberService {
    @Autowired
    private TJ_TMemberMapper tj_tMemberMapper;//会员表
    @Autowired
    private Tj_VipsettingMapper tjVipsettingMapper;
    //生成档案号的格式
    SimpleDateFormat sdfTime = new SimpleDateFormat("yyyyMMddHHmmss");
    Date d=new Date();
    //查询会员表全部数据
    @Override
    public List<TMember> queryAll() {
        return tj_tMemberMapper.queryAll();
    }

    @Override
    public List<TMember> queryLike(TMember tMember) {
        return tj_tMemberMapper.queryLike(tMember);
    }

    @Override
    public Integer delTmember(int id) {
        return tj_tMemberMapper.delTmember(id);
    }

    @Override
    public TMember queryById(int id) {
        return tj_tMemberMapper.queryById(id);
    }


    @Override
    public int updTmember(TMember tMember) {
        return tj_tMemberMapper.updTmember(tMember);
    }

    @Override
    public int addTmember(TMember tMember) {
        //设置档案号
        String format = String.format(sdfTime.format(new Date()),tj_tMemberMapper.getMysqlId()+1);
        tMember.setFileNumber(format);
        Date today = new Date(System.currentTimeMillis());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = simpleDateFormat.format(today);
        tMember.setCreatetime(date);
        tjVipsettingMapper.add(date);
        int i = tj_tMemberMapper.addTmember(tMember);

        return i;
    }



    @Override
    public TMember queryBytmemberId(int id) {
        return tj_tMemberMapper.queryBytmemberId(id);
    }

    @Override
    public TMember queryByIsCard(String idCard) {
        return tj_tMemberMapper.queryByIsCard(idCard);
    }


}
